module Classes {

    export class Player extends BaseObject {

        public shootType: number;
        private shootInterval: number;
        private shootTime: number;

        constructor() {
            super();
            this.config("player", "ally");
            
            this.shootType     = 1;
            this.shootInterval = 500;
            this.shootTime     = new Date().valueOf() - 2000;

            this.pos(240, 700);

            this.body.on("complete", this, this.onComplete);
        }

        public onLoop(): void {
            let curTime = new Date().valueOf();
            if (curTime - this.shootTime > this.shootInterval) {
                this.shootTime = curTime;
                Manager.GameManager.getInstance().createBullet(this);
            }
        }

        public changeShootType(type: number) {
            if (type < 1) type = 1;
            this.shootType = type;
            
            if (this.shootType > 1) {
                let glowFilter: Laya.GlowFilter = new Laya.GlowFilter("#ffff00", 10, 0, 0);
                this.filters = [glowFilter];
            } else {
                this.filters = [];
            }
        }

        public looseBlood(num: number): void {
            super.looseBlood(num);
            
            if (num > 0) {
                // Because Add Blood Also Use This Method.
                this.changeShootType(Math.floor(this.shootType / 2));
                Manager.DataManager.getInstance().blood = this.blood;
                if (this.blood < 0) {
                    gameInstance.stop();
                }
            }
        }
    }

}